<template>

  <div class="app-container">
    <el-form :inline="true" :model="roomCondition" class="demo-form-inline">
      <el-form-item label="小区名">
        <el-input v-model="roomCondition.quartersName" placeholder="请输入小区名称"></el-input>
      </el-form-item>

      <el-form-item label="业主">
        <el-input v-model="roomCondition.ownerName" placeholder="请输入业主姓名"></el-input>
      </el-form-item>

      <el-form-item>
        <el-button type="primary" @click="searchRoom()">查询</el-button>
      </el-form-item>
    </el-form>


    <el-table
      :data="ownerList"
      stripe
      style="width: 100%">


      <el-table-column
        prop="id"
        label="id"
        width="70">
      </el-table-column>


      <el-table-column
        prop="ownerName"
        label="业主姓名"
        width="120">
      </el-table-column>

      <el-table-column
        prop="qname"
        label="托管房源小区"
        width="120">
      </el-table-column>

      <el-table-column
        prop="room.build"
        label="托管房源楼栋"
        width="120">
      </el-table-column>


      <el-table-column
        prop="room.number"
        label="托管房源房号"
        width="120">
      </el-table-column>


      <el-table-column
        prop="phone"
        label="业主电话"
        width="120">
      </el-table-column>

      <el-table-column
        prop="identity"
        label="业主身份证">
      </el-table-column>


      <el-table-column
        prop="bankNum"
        label="收款银行卡">
      </el-table-column>

    </el-table>



  <div class="block">
    <el-pagination
      layout="total, sizes, prev, pager, next, jumper"
      @size-change="handleSizeChange"
      @current-change="handleCurrentChange"
      :page-sizes="[5,10,15,20]"
      :page-size="size"
      :total="total"
      :current-page.sync="num">
    </el-pagination>
  </div>
  </div>
</template>

<script>
import Owner from "@/api/owner";

export default {
  name: "list",
  data() {
    return {
      num: 1,
      size: 10,
      total: 0,
      ownerList: [],
      roomCondition: {
        quartersName: '',
        ownerName: ''
      }

    }
  },
  created() {
    this.initOwner();
  },
  methods: {

    handleCurrentChange(num) {
      this.num = num
      this.initOwner()
    },
    handleSizeChange(size) {
      this.num = 1
      this.size = size
      this.initOwner()

    },
    searchRoom() {
      console.log(this.roomCondition)
      this.initOwner();
    },
    initOwner() {
      console.log("initOwner")
      Owner.getList(this.num, this.size, this.roomCondition)
        .then(res => {
          const {data} = res;
          this.ownerList = data.ownerList.list
          this.num = data.ownerList.pageNum;
          this.size = data.ownerList.pageSize;
          this.total = data.ownerList.total;
        })
    }
  }
}
</script>
